
//LCR 169. 招式拆解 II
class Solution {
    public char dismantlingAction(String arr) {
        int[] arr1 = new int[26];
        for (int i = 0; i < arr.length(); i++) {
            arr1[arr.charAt(i) - 'a']++;
        }
        for (int i = 0; i < arr.length(); i++) {
            if (arr1[arr.charAt(i) - 'a'] == 1)
                return arr.charAt(i);
        }
        return ' ';
    }
}





//力扣143. 重排链表
class ListNode {
  int val;
  ListNode next;
  ListNode() {}
  ListNode(int val) { this.val = val; }
  ListNode(int val, ListNode next) { this.val = val; this.next = next; }
  }

class Solution1 {
    public void reorderList(ListNode head) {
        // 找到中节点
        ListNode fast = head;
        ListNode slow = head;
        while (fast != null && fast.next != null) {
            slow = slow.next;
            fast = fast.next.next;
        }

        // 反转右链表
        ListNode cur = slow.next;
        slow.next = null;
        while (cur != null) {
            ListNode curN = cur.next;
            cur.next = slow;
            slow = cur;
            cur = curN;
        }

        //构建新链表
        ListNode newN = new ListNode(-1);
        cur = head;
        ListNode temp = newN;
        while(cur!=null&&slow!=null){
            if(slow==cur){
                temp.next=cur;
                break;
            }
            temp.next=cur;
            temp=temp.next;
            cur=cur.next;

            temp.next=slow;
            temp=temp.next;
            slow=slow.next;
        }

        //在 Java 中，链表是通过指针（即 next）链接的。当你修改 temp.next 时，你实际上是在更新链表的指针，而不是创建新的节点。你通过 temp.next = cur 和 temp.next = slow 等操作，把原链表的节点按要求重新链接到一起。
    }
}